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,YAAaA,EAAaC,MAAOA,IACpD,GAAAZ,EAAAG,GAAA,EAACa,EAAAA,gBAAgBA,CAAAA,CACfC,MA5Ga,kBA6GbtC,KAAM,CAAEd,WAAAA,EAAYqB,mBAAAA,CAAmB,EACvCqB,QAAS/B,EACT0C,QAAS,CAAEC,OAAQ,EAAK,EACxBC,WAAYA,EAAAA,EAAUA,KAI9B","sources":["webpack://_N_E/?9b32","webpack://_N_E/./src/pages/collections/[...handle].tsx","webpack://_N_E/"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/collections/[...handle]\",\n function () {\n return require(\"private-next-pages/collections/[...handle].tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/collections/[...handle]\"])\n });\n }\n ","import type {\n GetStaticPathsContext,\n GetStaticPropsContext,\n InferGetStaticPropsType,\n} from \"next\";\nimport { useRouter } from \"next/router\";\nimport { useContext, useEffect, useState } from \"react\";\nimport { builder, BuilderComponent, useIsPreviewing } from \"@builder.io/react\";\nimport Head from \"next/head\";\n\nimport {\n getAllCollections,\n getCollectionProductsByHandle,\n} from \"@services/shopify/collections\";\nimport { resolveShopifyContent, renderLink } from \"@services/builderIO\";\nimport {\n CmsBridgeContext,\n CmsBridgeContextProps,\n} from \"@context/cms.bridge.context\";\nimport NotFound from \"@components/errors/not-found.component.tsx\";\nimport { NextSeo } from \"next-seo\";\n\nimport { trackViewPLP } from \"@lib/analytics.ts\";\n\n// Legacy\nimport Script from \"next/script\";\nimport SEO from \"@lib/seo\";\n\nconst builderModel = \"collection-page\";\n\nconst loadMore = async (handle: string, cursor: string) => {\n const collection = await getCollectionProductsByHandle({\n handle,\n to: 12,\n cursor,\n });\n return collection;\n};\n\n// Sort\nconst sortCollection = async (handle: string, option: string) => {\n const value = option.split(\"|\");\n const collection = await getCollectionProductsByHandle({\n handle,\n to: 12,\n sort: value[0],\n reverse: value[1] === \"true\" ? true : false,\n });\n return collection;\n};\n\nexport const getStaticProps = async ({\n params,\n}: GetStaticPropsContext<{ handle: string[] }>) => {\n return await resolveShopifyContent(\n builderModel,\n \"collection\",\n `/collections/${params?.handle[0]}`,\n {\n collectionHandle: params?.handle[0],\n }\n );\n};\n\nexport async function getStaticPaths(context: GetStaticPathsContext) {\n const collections = await getAllCollections();\n return {\n paths: collections.map(\n (collection: any) => `/collections/${collection.handle}`\n ),\n fallback: \"blocking\",\n };\n}\n\nexport default function CollectionPage({\n page,\n shopifyData,\n}: InferGetStaticPropsType) {\n const { collection, productList, ...data }: any = shopifyData;\n const { state, setState } =\n useContext(CmsBridgeContext);\n const isPreviewing = useIsPreviewing();\n const [collectionProducts, setCollectionProducts] = useState(productList);\n\n const dynamicRoute = useRouter().asPath;\n // Reset State on Route Change\n useEffect(() => {\n setCollectionProducts(productList);\n trackViewPLP(collection, productList);\n }, [dynamicRoute]);\n\n useEffect(() => {\n if (state.sortCollection) {\n sortCollection(collection.handle, state.sortCollection).then(\n (res: any) => {\n setCollectionProducts(res.productList);\n }\n );\n }\n\n if (state.handle) {\n loadMore(state.handle, state.cursor).then((res: any) => {\n if (res.productList) {\n collection.cursor = res.collection.cursor;\n collection.showingCount += res.collection.showingCount;\n // Adjust Total Count\n if (collection.totalCount > res.collection.totalCount) {\n collection.totalCount = res.collection.totalCount;\n }\n setCollectionProducts(collectionProducts.concat(res.productList));\n } else {\n collection.cursor = false;\n collection.totalCount = collectionProducts.length;\n }\n });\n }\n }, [state]);\n\n if ((!collection && !isPreviewing) || (!page && !isPreviewing)) {\n return (\n <>\n \n \n \n \n \n );\n }\n const { title, description, image } = page?.data! || {};\n\n builder.track(`collectionsPageView: ${collection.handle}`);\n\n return (\n <>\n \n \n \n );\n}\n"],"names":["window","__NEXT_P","push","__webpack_require__","loadMore","handle","cursor","collection","getCollectionProductsByHandle","to","sortCollection","option","value","split","sort","reverse","CollectionPage","param","page","shopifyData","productList","data","state","setState","useContext","CmsBridgeContext","isPreviewing","useIsPreviewing","collectionProducts","setCollectionProducts","useState","dynamicRoute","useRouter","asPath","useEffect","trackViewPLP","then","res","showingCount","totalCount","concat","length","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__","jsxs","Fragment","jsx","Head","meta","name","content","NotFound","type","title","description","image","builder","track","SEO","BuilderComponent","model","options","enrich","renderLink"],"sourceRoot":""}